const {
	exec
} = require('child_process');
const crypto = require('crypto');
const Response = require('./Response')
const {
	getTime,
} = require('../utils/dateUtils')
const {
	_UltDB,
	_WebDB,
	_SLMongo,
} = global

module.exports = {

	/**
	 * 资源分类列表
	 * @param  {[type]} params [description]
	 * @return {[type]}        [description]
	 */
	menu: async function() {
		let taskCol = await _SLMongo.getCollection('task')
		let docs = await taskCol.distinct('source')
		return new Response('000', '成功', {
			docs,
		})
	},

	/**
	 * 资源列表
	 * @param  {[type]} params [description]
	 * @return {[type]}        [description]
	 */
	list: async function(params) {
		let {
			source
		} = params
		let taskCol = await _SLMongo.getCollection('task')
		let docs = await taskCol.find({
			source,
		}).toArray()
		return new Response('000', '成功', {
			docs,
		})
	},

	clear: async function() {

	},

	goon: async function() {

	},

}

/**
 * 密码加密
 * @param  {[type]} password [description]
 * @return {[type]}          [description]
 */
function encPwd(password) {
	return crypto.createHash('md5').update(password).digest('hex');
}